package ch.fhnw.kosmonauten.client.gui;

import java.awt.Graphics;
import java.util.Arrays;

import javax.swing.JOptionPane;
import javax.swing.border.EmptyBorder;

import java.awt.Color;

import ch.fhnw.kosmonauten.client.core.HexagramModification;
import ch.fhnw.kosmonauten.client.core.Utility;
import ch.fhnw.kosmonauten.client.net.ServerConnection;
import ch.fhnw.kosmonauten.model.Category;
import ch.fhnw.kosmonauten.model.Hexagram;
import ch.fhnw.kosmonauten.model.Dossier;
import ch.fhnw.kosmonauten.model.User;
import ch.fhnw.kosmonauten.net.Request;
import ch.fhnw.kosmonauten.net.Response;
import ch.fhnw.kosmonauten.client.gui.HGPanel;


/**
 * Diese Klasse stellt das Situations-Hexagramm und dessen Umwandlung dar.
 * 
 * @author Fabian Siegrist
 * @author Oliver Freiermuth
 * @author Mikhail Onoufrienko
 * @author Risto Milani
 * @version $Revision: 234 $
 *          File name: $HeadURL: http://iching-kosmonauten.googlecode.com/svn/I-Ching/src/ch/fhnw/kosmonauten/client/gui/SituationPanel.java $
 *          Last modified:$Date: 2013-05-27 21:42:37 +0000 (Mon, 27 May 2013) $
 *          Last modified by: $Author: molotok.mihon@gmail.com $
 */

// class definition
public class SituationPanel extends javax.swing.JPanel {

	// attributes
	private User user;
	private ch.fhnw.kosmonauten.client.gui.Hexagram myHex, myHex2;
	private LineText lt1;
	private LineText lt2;
	private LineText lt3;
	private LineText lt4;
	private LineText lt5;
	private LineText lt6;
	private LineText lt1_perspective;
	private LineText lt2_perspective;
	private LineText lt3_perspective;
	private LineText lt4_perspective;
	private LineText lt5_perspective;
	private LineText lt6_perspective;
	private LineNote ln1;
	private LineNote ln2;
	private LineNote ln3;
	private LineNote ln4;
	private LineNote ln5;
	private LineNote ln6;
	private HGText ht;
	private HGComment hc;
	private boolean paint;
	private Dossier dossier;
	private ServerConnection sc;
	private ch.fhnw.kosmonauten.model.Hexagram situationmodel;
	private HGPanel perspective;
	private HGPanel nuclear;
	private HGPanel inverse;
	private HGPanel reverse; 
	private HGPanel fuxi;
	private MainWindow mainframe;
	
	// constructors
	/**
	 * @param paint
	 * @param dossier
	 */
	public SituationPanel(boolean paint, Dossier dossier, User user, 	HGPanel perspective, 
																		HGPanel nuclear, 
																		HGPanel inverse, 
																		HGPanel reverse, 
																		HGPanel fuxi,
																		MainWindow mainframe) {
		this.perspective = perspective;
		this.nuclear = nuclear;
		this.inverse = inverse;
		this.reverse = reverse;
		this.fuxi = fuxi;
		this.user = user;
		this.paint = paint;
		this.dossier = dossier;
		this.mainframe = mainframe;
		
		initComponents();
	}

	// methods
	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (paint) {
			myHex.paintComponent(g);
			myHex2.paintComponent(g);
		}
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {
		jComboBox1 = new javax.swing.JComboBox();
		jComboBox2 = new javax.swing.JComboBox();
		jComboBox3 = new javax.swing.JComboBox();
		jComboBox4 = new javax.swing.JComboBox();
		jComboBox5 = new javax.swing.JComboBox();
		jComboBox6 = new javax.swing.JComboBox();
		jButton1 = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();
		jLabel14 = new javax.swing.JLabel();
		jButton3 = new javax.swing.JButton();
		jButton4 = new javax.swing.JButton();
		jButton5 = new javax.swing.JButton();
		jButton6 = new javax.swing.JButton();
		jButton7 = new javax.swing.JButton();
		jButton8 = new javax.swing.JButton();
		jButton9 = new javax.swing.JButton();
		jButton10 = new javax.swing.JButton();
		jButton11 = new javax.swing.JButton();
		//jButton12 = new javax.swing.JButton();
		//jButton13 = new javax.swing.JButton();
		//jButton14 = new javax.swing.JButton();
		//jButton15 = new javax.swing.JButton();
		//jButton16 = new javax.swing.JButton();
		//jButton17 = new javax.swing.JButton();
		jButton18 = new javax.swing.JButton();
		jButton19 = new javax.swing.JButton();
		jButton20 = new javax.swing.JButton();
		jButton21 = new javax.swing.JButton();
		jButton22 = new javax.swing.JButton();
		jButton23 = new javax.swing.JButton();
		jButton24 = new javax.swing.JButton();
		jButton25 = new javax.swing.JButton();
		jButton26 = new javax.swing.JButton();
		jButton27 = new javax.swing.JButton();
		jButton28 = new javax.swing.JButton();
		jButton29 = new javax.swing.JButton();
		jLabel2 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jScrollPane3 = new javax.swing.JScrollPane();
		jTextArea3 = new javax.swing.JTextArea();
		jLabel5 = new javax.swing.JLabel();
		jScrollPane4 = new javax.swing.JScrollPane();
		jTextArea4 = new javax.swing.JTextArea();
		jButton30 = new javax.swing.JButton();
		jButton31 = new javax.swing.JButton();

		jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));
		jComboBox1.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jComboBox1ActionPerformed(evt);
			}
		});

		jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));

		jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));

		jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));

		jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));

		jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"6", "7", "8", "9" }));

		jButton1.setText(user.displayValue("mw47"));
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});

		jButton2.setText(user.displayValue("mw48"));
		jButton2.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton2ActionPerformed(evt);
			}
		});

		jLabel14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 16)); // NOI18N
		jLabel14.setText(user.displayValue("mw49"));

		jButton3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		jButton3.setText(user.displayValue("mw50"));
		jButton3.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton3ActionPerformed(evt);
			}
		});

		jButton4.setText(user.displayValue("mw51"));
		jButton4.setBorder(new EmptyBorder(5,5,5,5));
		jButton4.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton4ActionPerformed(evt);
			}
		});

		jButton5.setText(user.displayValue("mw52"));
		jButton5.setBorder(new EmptyBorder(5,5,5,5));
		jButton5.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton5ActionPerformed(evt);
			}
		});

		jButton6.setText(user.displayValue("mw53"));
		jButton6.setBorder(new EmptyBorder(5,5,5,5));   
		jButton6.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton6ActionPerformed(evt);
			}
		});

		jButton7.setText(user.displayValue("mw54"));
		jButton7.setBorder(new EmptyBorder(5,5,5,5));   
		jButton7.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton7ActionPerformed(evt);
			}
		});

		jButton8.setText(user.displayValue("mw55"));
		jButton8.setBorder(new EmptyBorder(5,5,5,5));   
		jButton8.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton8ActionPerformed(evt);
			}
		});

		jButton9.setText(user.displayValue("mw56"));
		jButton9.setBorder(new EmptyBorder(5,5,5,5));   
		jButton9.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton9ActionPerformed(evt);
			}
		});

		jButton10.setText(user.displayValue("mw57"));
		jButton10.setBorder(new EmptyBorder(5,5,5,5));   
		jButton10.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton10ActionPerformed(evt);
			}
		});

		jButton11.setText(user.displayValue("mw58"));
		jButton11.setBorder(new EmptyBorder(5,5,5,5));   
		jButton11.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton11ActionPerformed(evt);
			}
		});

		/*jButton12.setText(user.displayValue("mw59"));
		jButton12.setBorder(new EmptyBorder(5,5,5,5));   
		jButton12.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton12ActionPerformed(evt);
			}
		});*/

		/*jButton13.setText(user.displayValue("mw60"));
		jButton13.setBorder(new EmptyBorder(5,5,5,5));   
		jButton13.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton13ActionPerformed(evt);
			}
		});*/

		/*jButton14.setText(user.displayValue("mw61"));
		jButton14.setBorder(new EmptyBorder(5,5,5,5));   
		jButton14.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton14ActionPerformed(evt);
			}
		});*/

		/*jButton15.setText(user.displayValue("mw62"));
		jButton15.setBorder(new EmptyBorder(5,5,5,5));   
		jButton15.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton15ActionPerformed(evt);
			}
		});*/

		/*jButton16.setText(user.displayValue("mw63"));
		jButton16.setBorder(new EmptyBorder(5,5,5,5));   
		jButton16.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton16ActionPerformed(evt);
			}
		});*/

		/*jButton17.setText(user.displayValue("mw64"));
		jButton17.setBorder(new EmptyBorder(5,5,5,5));   
		jButton17.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton17ActionPerformed(evt);
			}
		});*/

		jButton18.setText(user.displayValue("mw65"));
		jButton18.setBorder(new EmptyBorder(5,5,5,5));   
		jButton18.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton18ActionPerformed(evt);
			}
		});

		jButton19.setText(user.displayValue("mw66"));
		jButton19.setBorder(new EmptyBorder(5,5,5,5));   
		jButton19.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton19ActionPerformed(evt);
			}
		});

		jButton20.setText(user.displayValue("mw67"));
		jButton20.setBorder(new EmptyBorder(5,5,5,5));   
		jButton20.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton20ActionPerformed(evt);
			}
		});

		jButton20.setText(user.displayValue("mw68"));
		jButton20.setBorder(new EmptyBorder(5,5,5,5));   
		jButton20.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton20ActionPerformed(evt);
			}
		});

		jButton21.setText(user.displayValue("mw69"));
		jButton21.setBorder(new EmptyBorder(5,5,5,5));   
		jButton21.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton21ActionPerformed(evt);
			}
		});

		jButton22.setText(user.displayValue("mw70"));
		jButton22.setBorder(new EmptyBorder(5,5,5,5));   
		jButton22.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton22ActionPerformed(evt);
			}
		});

		jButton23.setText(user.displayValue("mw71"));
		jButton23.setBorder(new EmptyBorder(5,5,5,5));   
		jButton23.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton23ActionPerformed(evt);
			}
		});

		jButton24.setText(user.displayValue("mw72"));
		jButton24.setBorder(new EmptyBorder(5,5,5,5));   
		jButton24.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton24ActionPerformed(evt);
			}
		});

		jButton25.setText(user.displayValue("mw73"));
		jButton25.setBorder(new EmptyBorder(5,5,5,5));   
		jButton25.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton25ActionPerformed(evt);
			}
		});

		jButton26.setText(user.displayValue("mw74"));
		jButton26.setBorder(new EmptyBorder(5,5,5,5));   
		jButton26.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton26ActionPerformed(evt);
			}
		});

		jButton27.setText(user.displayValue("mw75"));
		jButton27.setBorder(new EmptyBorder(5,5,5,5));   
		jButton27.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton27ActionPerformed(evt);
			}
		});

		jButton28.setText(user.displayValue("mw76"));
		jButton28.setBorder(new EmptyBorder(5,5,5,5));   
		jButton28.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton28ActionPerformed(evt);
			}
		});

		jButton29.setText(user.displayValue("mw77"));
		jButton29.setBorder(new EmptyBorder(5,5,5,5));  
		jButton29.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton29ActionPerformed(evt);
			}
		});

		jLabel2.setText("<html><body>"
				+ "----------------------------------------------------------------------------------------------------------------------<br>"
				+ "| Bitte binden Sie das Situation-Hexagramm:<br>"
				+ "| Danach kann das Hexagramm gespeichert werden<br>"
				+ "----------------------------------------------------------------------------------------------------------------------"
				+ "</body></html>");

		jLabel4.setText(user.displayValue("mw78"));

		jTextArea3.setColumns(20);
		jTextArea3.setRows(5);
		jScrollPane3.setViewportView(jTextArea3);

		jLabel5.setText(user.displayValue("mw79"));

		jTextArea4.setColumns(20);
		jTextArea4.setRows(5);
		jScrollPane4.setViewportView(jTextArea4);

		jButton30.setText(user.displayValue("mw80"));
		jButton30.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton30ActionPerformed(evt);
			}
		});

		jButton31.setText(user.displayValue("mw81"));
		jButton31.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton31ActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGap(61, 61, 61)
								.addComponent(jButton5,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										232,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(28, 28, 28)
								.addComponent(jLabel14)
								.addGap(27, 27, 27)
								.addComponent(jButton4,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										232,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGap(0, 0, Short.MAX_VALUE))
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addComponent(
																						jComboBox5,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jComboBox6,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jComboBox3,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jComboBox4,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jComboBox2,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addComponent(
																						jComboBox1,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.PREFERRED_SIZE))
																.addGap(224,
																		224,
																		224)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jButton22,
																														javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														jButton25,
																														javax.swing.GroupLayout.Alignment.TRAILING))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jButton23)
																												.addComponent(
																														jButton24)))
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jButton21)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jButton20))
																				.addGroup(
																						layout.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								false)
																								.addGroup(
																										layout.createSequentialGroup()
																												.addGroup(
																														layout.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																																.addComponent(
																																		jButton26,
																																		javax.swing.GroupLayout.Alignment.TRAILING)
																																.addComponent(
																																		jButton29,
																																		javax.swing.GroupLayout.Alignment.TRAILING))
																												.addPreferredGap(
																														javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																														javax.swing.GroupLayout.DEFAULT_SIZE,
																														Short.MAX_VALUE)
																												.addGroup(
																														layout.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																																.addComponent(
																																		jButton27)
																																.addComponent(
																																		jButton28)))
																								.addGroup(
																										layout.createSequentialGroup()
																												.addComponent(
																														jButton18)
																												.addPreferredGap(
																														javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																												.addComponent(
																														jButton19))))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		Short.MAX_VALUE)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jButton7,
																														javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														jButton9,
																														javax.swing.GroupLayout.Alignment.TRAILING))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								/*.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jButton14)
																												.addComponent(
																														jButton15))*/)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jButton8)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								/*.addComponent(
																										jButton13)*/)
																				.addGroup(
																						layout.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								false)
																								.addGroup(
																										layout.createSequentialGroup()
																												.addGroup(
																														layout.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																																.addComponent(
																																		jButton10,
																																		javax.swing.GroupLayout.Alignment.TRAILING)
																																.addComponent(
																																		jButton11,
																																		javax.swing.GroupLayout.Alignment.TRAILING))
																												.addPreferredGap(
																														javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																														javax.swing.GroupLayout.DEFAULT_SIZE,
																														Short.MAX_VALUE)
																												/*.addGroup(
																														layout.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																																.addComponent(
																																		jButton16)
																																.addComponent(
																																		jButton17))*/)
																								.addGroup(
																										layout.createSequentialGroup()
																												.addComponent(
																														jButton6)
																												.addPreferredGap(
																														javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																												/*.addComponent(
																														jButton12)*/))))
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING,
																				false)
																				.addComponent(
																						jButton2,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						Short.MAX_VALUE)
																				.addComponent(
																						jButton1,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						157,
																						Short.MAX_VALUE))
																.addGap(6, 6, 6)
																.addComponent(
																		jButton3)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jLabel2)
																.addGap(0,
																		0,
																		Short.MAX_VALUE))))
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(jScrollPane3)
												.addComponent(jScrollPane4)
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel4)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jButton30))
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel5)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jButton31)))
																.addGap(0,
																		0,
																		Short.MAX_VALUE)))));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jButton4)
												.addComponent(jButton5)
												.addComponent(jLabel14))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														javax.swing.GroupLayout.Alignment.TRAILING,
														layout.createSequentialGroup()
																.addComponent(
																		jComboBox1,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jComboBox2,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jComboBox3,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jComboBox4,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jComboBox5,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																.addComponent(
																		jComboBox6,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		javax.swing.GroupLayout.DEFAULT_SIZE,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addGap(27, 27,
																		27))
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton6)
																												/*.addComponent(
																														jButton12)*/)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton8)
																												/*.addComponent(
																														jButton13)*/)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton7)
																												/*.addComponent(
																														jButton14)*/)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton9)
																												/*.addComponent(
																														jButton15)*/)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton10)
																												/*.addComponent(
																														jButton16)*/)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton11)
																												/*.addComponent(
																														jButton17)*/))
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton18)
																												.addComponent(
																														jButton19))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton21)
																												.addComponent(
																														jButton20))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton22)
																												.addComponent(
																														jButton23))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton25)
																												.addComponent(
																														jButton24))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton26)
																												.addComponent(
																														jButton27))
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																												.addComponent(
																														jButton29)
																												.addComponent(
																														jButton28))))
																.addGap(18, 18,
																		18)))
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(jLabel2)
												.addGroup(
														layout.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
																.addGroup(
																		layout.createSequentialGroup()
																				.addComponent(
																						jButton2)
																				.addPreferredGap(
																						javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																						javax.swing.GroupLayout.DEFAULT_SIZE,
																						Short.MAX_VALUE)
																				.addComponent(
																						jButton1))
																.addGroup(
																		layout.createSequentialGroup()
																				.addComponent(
																						jButton3,
																						javax.swing.GroupLayout.PREFERRED_SIZE,
																						48,
																						javax.swing.GroupLayout.PREFERRED_SIZE)
																				.addGap(0,
																						0,
																						Short.MAX_VALUE))))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel4)
												.addComponent(jButton30))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(jScrollPane3,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										56, Short.MAX_VALUE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel5)
												.addComponent(jButton31))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(jScrollPane4,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										56, Short.MAX_VALUE).addGap(37, 37, 37)));
	}// </editor-fold>

	private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		int[] numbers = Utility.generateRandom(6, 9, 6);
		jComboBox1.setSelectedItem(Integer.toString(numbers[0]));
		jComboBox2.setSelectedItem(Integer.toString(numbers[1]));
		jComboBox3.setSelectedItem(Integer.toString(numbers[2]));
		jComboBox4.setSelectedItem(Integer.toString(numbers[3]));
		jComboBox5.setSelectedItem(Integer.toString(numbers[4]));
		jComboBox6.setSelectedItem(Integer.toString(numbers[5]));
	}
	
	public void bindDossier()
	{
		// Frage
		dossier.setQuestion(this.mainframe.getjTextArea1().getText());
		// Analyse
		dossier.setAnalyse(this.mainframe.getjTextArea12().getText());
		// Syntthese
		dossier.setSynthese(this.mainframe.getjTextArea15().getText());
		// Fazit
		dossier.setExperience(this.mainframe.getjTextArea14().getText());
		dossier.setPrivacy((mainframe.getjRadioButton1().isSelected() ? 1 : 0));
		
		// Situation Hexagramm comment
		dossier.setTepmHexSitComment(this.jTextArea3.getText());
		dossier.setTempHexSitID(Integer.toString(this.situationmodel.getHexagramID()));
		// Situation Hexagramm dossier comment
		dossier.setSituation(this.jTextArea4.getText());
		// Situation Hexagramm Line1 comment
		dossier.setSit_line1((ln1 == null) ? "" : this.ln1.getjTextArea1().getText());
		// Situation Hexagramm Line2 comment
		dossier.setSit_line2((ln2 == null) ? "" : this.ln2.getjTextArea1().getText());
		// Situation Hexagramm Line3 comment
		dossier.setSit_line3((ln3 == null) ? "" : this.ln3.getjTextArea1().getText());
		// Situation Hexagramm Line4 comment
		dossier.setSit_line4((ln4 == null) ? "" : this.ln4.getjTextArea1().getText());
		// Situation Hexagramm Line5 comment
		dossier.setSit_line5((ln5 == null) ? "" : this.ln5.getjTextArea1().getText());
		// Situation Hexagramm Line6 comment
		dossier.setSit_line6((ln6 == null) ? "" : this.ln6.getjTextArea1().getText());
		
		
		//Perspective Hexagramm comment
		dossier.setTepmHexPerComment(this.perspective.getjTextArea1().getText());
		dossier.setTempHexPerID(Integer.toString(this.situationmodel.getPerspective().getHexagramID()));
		//Perspective Hexagramm dossier comment
		dossier.setPerspective(this.perspective.getjTextArea2().getText());
		// Perspective Hexagramm Line1 comment
		dossier.setPer_line1((perspective.getLn1() == null) ? "" : this.perspective.getLn1().getjTextArea1().getText());
		// Perspective Hexagramm Line2 comment
		dossier.setPer_line2((perspective.getLn2() == null) ? "" : this.perspective.getLn2().getjTextArea1().getText());
		// Perspective Hexagramm Line3 comment
		dossier.setPer_line3((perspective.getLn3() == null) ? "" : this.perspective.getLn3().getjTextArea1().getText());
		// Perspective Hexagramm Line4 comment
		dossier.setPer_line4((perspective.getLn4() == null) ? "" : this.perspective.getLn4().getjTextArea1().getText());
		// Perspective Hexagramm Line5 comment
		dossier.setPer_line5((perspective.getLn5() == null) ? "" : this.perspective.getLn5().getjTextArea1().getText());
		// Perspective Hexagramm Line6 comment
		dossier.setPer_line6((perspective.getLn6() == null) ? "" : this.perspective.getLn6().getjTextArea1().getText());
		
		//Nuclear Hexagramm comment
		dossier.setTepmHexNucComment(this.nuclear.getjTextArea1().getText());
		dossier.setTempHexNucID(Integer.toString(this.situationmodel.getNuclear().getHexagramID()));
				//Nuclear Hexagramm dossier comment
		dossier.setNuclear(this.nuclear.getjTextArea2().getText());
				// Nuclear Hexagramm Line1 comment
		dossier.setNuc_line1((nuclear.getLn1() == null) ? "" : this.nuclear.getLn1().getjTextArea1().getText());
				// Nuclear Hexagramm Line2 comment
		dossier.setNuc_line2((nuclear.getLn2() == null) ? "" : this.nuclear.getLn2().getjTextArea1().getText());
				// Nuclear Hexagramm Line3 comment
		dossier.setNuc_line3((nuclear.getLn3() == null) ? "" : this.nuclear.getLn3().getjTextArea1().getText());
				// Nuclear Hexagramm Line4 comment
		dossier.setNuc_line4((nuclear.getLn4() == null) ? "" : this.nuclear.getLn4().getjTextArea1().getText());
				// Nuclear Hexagramm Line5 comment
		dossier.setNuc_line5((nuclear.getLn5() == null) ? "" : this.nuclear.getLn5().getjTextArea1().getText());
				// Nuclear Hexagramm Line6 comment
		dossier.setNuc_line6((nuclear.getLn6() == null) ? "" : this.nuclear.getLn6().getjTextArea1().getText());
		
		//inverse Hexagramm comment
		dossier.setTepmHexInvComment(this.inverse.getjTextArea1().getText());
		dossier.setTempHexInvID(Integer.toString(this.situationmodel.getInverse().getHexagramID()));
		//inverse Hexagramm dossier comment
		dossier.setInverse(this.inverse.getjTextArea2().getText());
		// inverse Hexagramm Line1 comment
		dossier.setInv_line1((inverse.getLn1() == null) ? "" : this.inverse.getLn1().getjTextArea1().getText());
		// inverse Hexagramm Line2 comment
		dossier.setInv_line2((inverse.getLn2() == null) ? "" : this.inverse.getLn2().getjTextArea1().getText());
		// inverse Hexagramm Line3 comment
		dossier.setInv_line3((inverse.getLn3() == null) ? "" : this.inverse.getLn3().getjTextArea1().getText());
		// inverse Hexagramm Line4 comment
		dossier.setInv_line4((inverse.getLn4() == null) ? "" : this.inverse.getLn4().getjTextArea1().getText());
		// inverse Hexagramm Line5 comment
		dossier.setInv_line5((inverse.getLn5() == null) ? "" : this.inverse.getLn5().getjTextArea1().getText());
		// inverse Hexagramm Line6 comment
		dossier.setInv_line6((inverse.getLn6() == null) ? "" : this.inverse.getLn6().getjTextArea1().getText());
		
		//reverse Hexagramm comment
		dossier.setTepmHexRevComment(this.reverse.getjTextArea1().getText());
		dossier.setTempHexRevID(Integer.toString(this.situationmodel.getReverse().getHexagramID()));
		//reverse Hexagramm dossier comment
		dossier.setReverse(this.reverse.getjTextArea2().getText());
		// reverse Hexagramm Line1 comment
		dossier.setRev_line1((reverse.getLn1() == null) ? "" : this.reverse.getLn1().getjTextArea1().getText());
		// reverse Hexagramm Line2 comment
		dossier.setRev_line2((reverse.getLn2() == null) ? "" : this.reverse.getLn2().getjTextArea1().getText());
		// reverse Hexagramm Line3 comment
		dossier.setRev_line3((reverse.getLn3() == null) ? "" : this.reverse.getLn3().getjTextArea1().getText());
		// reverse Hexagramm Line4 comment
		dossier.setRev_line4((reverse.getLn4() == null) ? "" : this.reverse.getLn4().getjTextArea1().getText());
		// reverse Hexagramm Line5 comment
		dossier.setRev_line5((reverse.getLn5() == null) ? "" : this.reverse.getLn5().getjTextArea1().getText());
		// reverse Hexagramm Line6 comment
		dossier.setRev_line6((reverse.getLn6() == null) ? "" : this.reverse.getLn6().getjTextArea1().getText());
		
		//fuxi Hexagramm comment
		dossier.setTepmHexFuxComment(this.fuxi.getjTextArea1().getText());
		dossier.setTempHexFuxID(Integer.toString(this.situationmodel.getFuxi().getHexagramID()));
		//fuxi Hexagramm dossier comment
		dossier.setFuxi(fuxi.getjTextArea2().getText());
		// fuxi Hexagramm Line1 comment
		dossier.setFux_line1((fuxi.getLn1() == null) ? "" : this.fuxi.getLn1().getjTextArea1().getText());
		// fuxi Hexagramm Line2 comment
		dossier.setFux_line2((fuxi.getLn2() == null) ? "" : this.fuxi.getLn2().getjTextArea1().getText());
		// fuxi Hexagramm Line3 comment
		dossier.setFux_line3((fuxi.getLn3() == null) ? "" : this.fuxi.getLn3().getjTextArea1().getText());
		// fuxi Hexagramm Line4 comment
		dossier.setFux_line4((fuxi.getLn4() == null) ? "" : this.fuxi.getLn4().getjTextArea1().getText());
		// fuxi Hexagramm Line5 comment
		dossier.setFux_line5((fuxi.getLn5() == null) ? "" : this.fuxi.getLn5().getjTextArea1().getText());
		// fuxi Hexagramm Line6 comment
		dossier.setFux_line6((fuxi.getLn6() == null) ? "" : this.fuxi.getLn6().getjTextArea1().getText());
		
	}

	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
		
		showHexagram();
		
	}

	public void showHexagram() {
		int[] situation = new int[] {
				Integer.parseInt(jComboBox1.getSelectedItem().toString()),
				Integer.parseInt(jComboBox2.getSelectedItem().toString()),
				Integer.parseInt(jComboBox3.getSelectedItem().toString()),
				Integer.parseInt(jComboBox4.getSelectedItem().toString()),
				Integer.parseInt(jComboBox5.getSelectedItem().toString()),
				Integer.parseInt(jComboBox6.getSelectedItem().toString()) };

		int[] perspective = HexagramModification.getPerspective(situation);

		myHex = new ch.fhnw.kosmonauten.client.gui.Hexagram(situation, 37, 60);
		myHex2 = new ch.fhnw.kosmonauten.client.gui.Hexagram(perspective, 37, 481);
		this.dossier.setBinarycode(Arrays
				.toString(HexagramModification.getBinaryCode(situation))
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		this.dossier.setHexagramcode(Arrays.toString(situation)
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		this.dossier.setBinarycodePerspective(Arrays
				.toString(HexagramModification.getBinaryCode(perspective))
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		
		// Hexagramm texte Text aus der DB holen
		sc = new ServerConnection();
		Response resp = sc.sendRequest(new Request(this.dossier,"getHexagramTextSitAndPer"));
		if (resp == null)
			System.out.println(user.displayValue("mw82"));
		else if (resp.getContent() instanceof Hexagram) {
			situationmodel = (Hexagram) resp.getContent();
			jButton5.setText(situationmodel.getHexagramname());
			jButton4.setText(situationmodel.getPerspective().getHexagramname());
			
			this.paint = true;
			this.add(myHex);
			this.add(myHex2);
			this.repaint();
			
			this.nuclear.paint = true;
			this.nuclear.setModelhex(situationmodel.getNuclear());
			this.nuclear.setGuihex(situationmodel.getNuclear());
			this.nuclear.repaint();
			
			this.perspective.paint = true;
			this.perspective.setModelhex(situationmodel.getPerspective());
			this.perspective.setGuihex(situationmodel.getPerspective());
			this.perspective.repaint();
			
			this.inverse.paint = true;
			this.inverse.setModelhex(situationmodel.getInverse());
			this.inverse.setGuihex(situationmodel.getInverse());
			this.inverse.repaint();
			
			this.reverse.paint = true;
			this.reverse.setModelhex(situationmodel.getReverse());
			this.reverse.setGuihex(situationmodel.getReverse());
			this.reverse.repaint();
			
			this.fuxi.paint = true;
			this.fuxi.setModelhex(situationmodel.getFuxi());
			this.fuxi.setGuihex(situationmodel.getFuxi());
			this.fuxi.repaint();
			
		}else if (resp.getContent() == null )
		{
			new ErrorDialog(3, JOptionPane.INFORMATION_MESSAGE, user);
		}
		else
			System.out.println(resp.getContent().toString());
		// ENDE der DB
	}
	
	public void showHexagram(String hexagramcode, Dossier dos) {
		int[] situation = Utility.convertStringToArray(hexagramcode);
		int[] perspective = HexagramModification.getPerspective(situation);

		this.dossier = dos;
		
		myHex = new ch.fhnw.kosmonauten.client.gui.Hexagram(situation, 37, 60);
		myHex2 = new ch.fhnw.kosmonauten.client.gui.Hexagram(perspective, 37, 481);
		this.dossier.setBinarycode(Arrays
				.toString(HexagramModification.getBinaryCode(situation))
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		this.dossier.setHexagramcode(Arrays.toString(situation)
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		this.dossier.setBinarycodePerspective(Arrays
				.toString(HexagramModification.getBinaryCode(perspective))
				.replace(",", "").replace("[", "").replace("]", "")
				.replace(" ", ""));
		
		// Hexagramm texte Text aus der DB holen
		sc = new ServerConnection();
		Response resp = sc.sendRequest(new Request(this.dossier,"getHexagramTextSitAndPer"));
		if (resp == null)
			System.out.println(user.displayValue("mw82"));
		else if (resp.getContent() instanceof Hexagram) {
			situationmodel = (Hexagram) resp.getContent();
			jButton5.setText(situationmodel.getHexagramname());
			jButton4.setText(situationmodel.getPerspective().getHexagramname());
			
			this.paint = true;
			this.add(myHex);
			this.add(myHex2);
			this.repaint();
			
			this.nuclear.paint = true;
			this.nuclear.setModelhex(situationmodel.getNuclear());
			this.nuclear.setGuihex(situationmodel.getNuclear());
			this.nuclear.repaint();
			
			this.perspective.paint = true;
			this.perspective.setModelhex(situationmodel.getPerspective());
			this.perspective.setGuihex(situationmodel.getPerspective());
			this.perspective.repaint();
			
			this.inverse.paint = true;
			this.inverse.setModelhex(situationmodel.getInverse());
			this.inverse.setGuihex(situationmodel.getInverse());
			this.inverse.repaint();
			
			this.reverse.paint = true;
			this.reverse.setModelhex(situationmodel.getReverse());
			this.reverse.setGuihex(situationmodel.getReverse());
			this.reverse.repaint();
			
			this.fuxi.paint = true;
			this.fuxi.setModelhex(situationmodel.getFuxi());
			this.fuxi.setGuihex(situationmodel.getFuxi());
			this.fuxi.repaint();
			
		}else if (resp.getContent() == null )
		{
			new ErrorDialog(3, JOptionPane.INFORMATION_MESSAGE, user);
		}
		else
			System.out.println(resp.getContent().toString());
		// ENDE der DB
	}

	private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt6_perspective == null)
			lt6_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "6",situationmodel.getPerspective().getLine6text());
		else
			lt6_perspective.setVisible(true);
	}

	private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt4_perspective == null)
			lt4_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "4",situationmodel.getPerspective().getLine4text());
		else
			lt4_perspective.setVisible(true);
	}

	private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt5_perspective == null)
			lt5_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "5",situationmodel.getPerspective().getLine5text());
		else
			lt5_perspective.setVisible(true);
	}

	private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt3_perspective == null)
			lt3_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "3",situationmodel.getPerspective().getLine3text());
		else
			lt3_perspective.setVisible(true);
	}

	private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt2_perspective == null)
			lt2_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "2",situationmodel.getPerspective().getLine2text());
		else
			lt2_perspective.setVisible(true);
	}

	private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt1_perspective == null)
			lt1_perspective = new LineText(situationmodel.getPerspective().getHexagramname(), "1",situationmodel.getPerspective().getLine1text());
		else
			lt1_perspective.setVisible(true);
	}

	/*private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln6 != null)
			ln6 = new LineNote("Boew", "6", 56, user);
		else
			ln6.setVisible(true);
	}

	private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln5 != null)
			ln5 = new LineNote("Boew", "5", 56, user);
		else
			ln5.setVisible(true);
	}
	
	private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln4 != null)
			ln4 = new LineNote("Boew", "4", 56, user);
		else
			ln4.setVisible(true);
	}

	private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln3 != null)
			ln3 = new LineNote("Boew", "3", 56, user);
		else
			ln3.setVisible(true);
	}

	private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln2 != null)
			ln2 = new LineNote("Boew", "2", 56, user);
		else
			ln2.setVisible(true);
	}

	private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln1 != null)
			ln1 = new LineNote("Boew", "1", 56, user);
		else
			ln1.setVisible(true);
	}*/

	private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt6 == null)
			lt6 = new LineText(situationmodel.getHexagramname(), "6",situationmodel.getLine6text());
		else
			lt6.setVisible(true);
		
	}

	private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		if (ln6 == null)
			ln6 = new LineNote("Boew", "6", user);
		else
			ln6.setVisible(true);
	}

	private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln5 == null)
			ln5 = new LineNote("Boew", "5", user);
		else
			ln5.setVisible(true);
	}

	private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt5 == null)
			lt5 = new LineText(situationmodel.getHexagramname(), "5",situationmodel.getLine5text());
		else
			lt5.setVisible(true);
	}

	private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt4 == null)
			lt4 = new LineText(situationmodel.getHexagramname(), "4",situationmodel.getLine4text());
		else
			lt4.setVisible(true);
	}

	private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln4 == null)
			ln4 = new LineNote("Boew", "4", user);
		else
			ln4.setVisible(true);
	}

	private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln3 == null)
			ln3 = new LineNote("Boew", "3", user);
		else
			ln3.setVisible(true);
	}

	private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt3 == null)
			lt3 = new LineText(situationmodel.getHexagramname(), "3",situationmodel.getLine3text());
		else
			lt3.setVisible(true);
	}

	private void jButton26ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt2 == null)
			lt2 = new LineText(situationmodel.getHexagramname(), "2",situationmodel.getLine2text());
		else
			lt2.setVisible(true);
	}

	private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln2 == null)
			ln2 = new LineNote("Boew", "2", user);
		else
			ln2.setVisible(true);
	}

	private void jButton28ActionPerformed(java.awt.event.ActionEvent evt) {
		if (ln1 == null)
			ln1 = new LineNote("Boew", "1", user);
		else
			ln1.setVisible(true);
	}

	private void jButton29ActionPerformed(java.awt.event.ActionEvent evt) {
		if (lt1 == null)
			lt1 = new LineText(situationmodel.getHexagramname(), "1",situationmodel.getLine1text());
		else
			lt1.setVisible(true);
	}

	private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
		try
		{
			if (dossier.getBinarycode() != null)
			{
				dossier.setDossierID(-1);
				this.bindDossier();
				// Dossier speichern
				sc = new ServerConnection();
				Response resp = sc.sendRequest(new Request(this.dossier,"saveDossier"));
				if (resp == null)
					System.out.println(user.displayValue("mw82"));
				else if (resp.getContent() instanceof Dossier) 
				{
					this.dossier = (Dossier) resp.getContent();
					if (this.dossier.getDossierID() != null)
					{
						if (this.dossier.getDossierID() != -1)
						{
							jButton3.setEnabled(false);
							jLabel2.setVisible(false);
							jButton1.setEnabled(false);
							jButton2.setEnabled(false);
							jComboBox1.setEditable(false);
							jComboBox2.setEditable(false);
							jComboBox3.setEditable(false);
							jComboBox4.setEditable(false);
							jComboBox5.setEditable(false);
							jComboBox6.setEditable(false);
							dossier.setBounded(true);
							mainframe.setNewdossier(dossier);
						}
						else
							new ErrorDialog(4, JOptionPane.ERROR_MESSAGE, user);
					}
					else
						new ErrorDialog(4, JOptionPane.ERROR_MESSAGE, user);	
				}
				else if (resp.getContent() == null )
				{
					new ErrorDialog(5, JOptionPane.ERROR_MESSAGE, user);
				}
				else
					new ErrorDialog(resp.getContent().toString());
			}
			else
				new ErrorDialog(11, JOptionPane.INFORMATION_MESSAGE, user);
		}
		catch (Exception e)
		{
			new ErrorDialog(e.getMessage());
		}
		
	}

	private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		ht = new HGText(situationmodel.getHexagramname(), situationmodel.getJudge(), situationmodel.getComment(), user);
	}

	private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		ht = new HGText(situationmodel.getHexagramname(), situationmodel.getJudge(), situationmodel.getComment(), user);
	}

	private void jButton30ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		hc = new HGComment(12, "ein Name", false, user);
	}

	private void jButton31ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		hc = new HGComment(12, "ein Name", true, user);
	}

	// Variables declaration - do not modify
	private javax.swing.JButton jButton1;
	private javax.swing.JButton jButton10;
	private javax.swing.JButton jButton11;
	/*private javax.swing.JButton jButton12;
	private javax.swing.JButton jButton13;
	private javax.swing.JButton jButton14;
	private javax.swing.JButton jButton15;
	private javax.swing.JButton jButton16;
	private javax.swing.JButton jButton17;*/
	private javax.swing.JButton jButton18;
	private javax.swing.JButton jButton19;
	private javax.swing.JButton jButton2;
	private javax.swing.JButton jButton20;
	private javax.swing.JButton jButton21;
	private javax.swing.JButton jButton22;
	private javax.swing.JButton jButton23;
	private javax.swing.JButton jButton24;
	private javax.swing.JButton jButton25;
	private javax.swing.JButton jButton26;
	private javax.swing.JButton jButton27;
	private javax.swing.JButton jButton28;
	private javax.swing.JButton jButton29;
	private javax.swing.JButton jButton3;
	private javax.swing.JButton jButton30;
	private javax.swing.JButton jButton31;
	private javax.swing.JButton jButton4;
	private javax.swing.JButton jButton5;
	private javax.swing.JButton jButton6;
	private javax.swing.JButton jButton7;
	private javax.swing.JButton jButton8;
	private javax.swing.JButton jButton9;
	private javax.swing.JComboBox jComboBox1;
	private javax.swing.JComboBox jComboBox2;
	private javax.swing.JComboBox jComboBox3;
	private javax.swing.JComboBox jComboBox4;
	private javax.swing.JComboBox jComboBox5;
	private javax.swing.JComboBox jComboBox6;
	private javax.swing.JLabel jLabel14;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JScrollPane jScrollPane3;
	private javax.swing.JScrollPane jScrollPane4;
	private javax.swing.JTextArea jTextArea3;
	private javax.swing.JTextArea jTextArea4;
	// End of variables declaration
}
